-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new module TroykaMeteoSensor #71
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поправил пунктуацию и кодстайл в документации
@@ -0,0 +1,113 @@ | |||
function TroykaMeteoSensor(opts) { | |||
opts = opts || {}; | |||
var _i2c = opts.i2c || PrimaryI2C; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в документации сказано, что объект opts ''должен'' содержать поля.
по факту он ''может'' содержать, но не обязан
modules/@amperka/meteo-sensor.js
Outdated
}; | ||
|
||
this.clockStretchingOn = function() { | ||
_clockStretching = "ON" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если Iskra JS не умеет пользоваться clockStretching, то лучше не давать ручку к нему.
modules/@amperka/meteo-sensor.js
Outdated
var data = _i2c.readFrom(_address, 6); | ||
if (data[2] != _checkCRC8(data, 0, 2) || data[5] != _checkCRC8(data, 3, 5)) { | ||
callback(new Error('checksum error'), { | ||
tempC: -1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не знаю как правильно, но я бы сделал undefined в случае ошибки. Так было бы проще отловить, что «что-то не то» в данных температуры. Иначе возникает вопрос «да почему минус один-то?», если человек не обрабатывает ошибки
Убрал выбор clockStretching, возвращаю undefined в случае ошибки, завернул все вызовы i2c в try...catch и возвращаю ошибку... |
LGTM |
LGTM |
http://wiki.amperka.ru/js:meteo-sensor
@igrztv
@igor89
@acosinwork